package callnumber.gtdev5.com.photoVault.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.request.RequestOptions;
import com.zhihu.matisse.engine.ImageEngine;

/**
 * Created by cheng
 * PackageName FakeCall
 * 2018/7/10 9:44
 */

public class GlideEngine implements ImageEngine {
    @Override
    public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
        RequestOptions options=new RequestOptions()
                .placeholder(placeholder)
                .override(resize, resize)
                .centerCrop();
        Glide.with(context)
                .load(uri)
                .apply(options)
                .into(imageView);
    }

    @Override
    public void loadAnimatedGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
        RequestOptions options=new RequestOptions()
                .placeholder(placeholder)
                .override(resize, resize)
                .centerCrop();
        Glide.with(context)
                .load(uri)
                .apply(options)
                .into(imageView);
    }

    @Override
    public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
        RequestOptions options=new RequestOptions()
                  .override(resizeX, resizeY)
                .priority(Priority.HIGH);
        Glide.with(context)
                .load(uri)
                 .apply(options)
                .into(imageView);
    }

    @Override
    public void loadAnimatedGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
        RequestOptions options=new RequestOptions()
                 .override(resizeX, resizeY)
                .priority(Priority.HIGH)
                .priority(Priority.HIGH);
        Glide.with(context)
                .load(uri)
                 .apply(options)
                .into(imageView);
    }

    @Override
    public boolean supportAnimatedGif() {
        return false;
    }
}
